package com.taikang.system.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.taikang.system.dao.ISysEmailServerConfigDao;
import com.taikang.system.entity.SysEmailServerConfig;
import com.taikang.system.service.ISysEmailServerConfigService;

@Transactional
@Service
public class SysEmailServerConfigServiceImpl implements ISysEmailServerConfigService{

	@Autowired
	private ISysEmailServerConfigDao configDao;
	
	@Override
	public SysEmailServerConfig getEmailServerConfig() {
		return configDao.getEmailServerConfig();
	}

	@Override
	public void update(SysEmailServerConfig config) {
		SysEmailServerConfig serverConfig = configDao.getEmailServerConfig();
		if(null==serverConfig){
			configDao.add(config);
		}else{
			serverConfig.setAccount(config.getAccount());
			serverConfig.setHostName(config.getHostName());
			serverConfig.setPassword(config.getPassword());
			serverConfig.setFromName(config.getFromName());
			configDao.update(serverConfig);
		}
	}

}
